<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'api\controllers',
    //模块
    'modules' => [
        'v1' => [
            'class' => 'api\modules\v1\Module',
        ],
    ],

    'components' => [
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],

        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

        #url美化
        'urlManager' => [
            'enablePrettyUrl' => true,      // 启用美化URL
            'enableStrictParsing' => false, // 是否执行严格的url解析 ,开启后它会走 rules [规则] ，且是严格按照规则来走的
            // 'enableStrictParsing' => false, // 是否执行严格的url解析
            'showScriptName' => false,     // 在URL路径中是否显示脚本入口文件
            // 'suffix'=>'.html',             // 伪静态，页面
            'rules' => [
                   [
                   'class' => 'yii\rest\UrlRule',
                   'controller' => ['v1/hello','v1/cat','v1/article'],
                    'pluralize' => false,    #去掉restful中默认使用的复数形式（s）;
                    'extraPatterns' => [
                        'GET about' => 'about',
                        'GET test' => 'test',
                        'GET index2' => 'index2',
                        'GET index' => 'index',
                        'GET catlist' => 'cat-list',
                        'GET articlelist' => 'article-list',

                     ],

                   ],

            ],
        ],

    ],
    'params' => $params,
];
